<?php
declare(strict_types=1);

namespace app\validate;

class ApplicationValidate extends BaseValidate
{
    protected $rule = [
        'application_name' => 'require|length:2,50',
        'application_type' => 'require|in:1,2,3,4,5',
        'app_id' => 'require|length:2,100',
        'app_secret' => 'require|length:2,100',
        'token' => 'length:0,100',
        'encoding_aes_key' => 'length:0,100',
        'additional_info' => 'array'
    ];

    protected $message = [
        'application_name.require' => '应用名称不能为空',
        'application_name.length' => '应用名称长度必须在2-50个字符之间',
        'application_type.require' => '应用类型不能为空',
        'application_type.in' => '应用类型不正确',
        'app_id.require' => 'AppID不能为空',
        'app_id.length' => 'AppID长度必须在2-100个字符之间',
        'app_secret.require' => 'AppSecret不能为空',
        'app_secret.length' => 'AppSecret长度必须在2-100个字符之间',
        'token.length' => 'Token长度必须在0-100个字符之间',
        'encoding_aes_key.length' => '加密密钥长度必须在0-100个字符之间',
        'additional_info.array' => '附加信息必须为数组'
    ];

    // 保存场景
    public function sceneSave(): ApplicationValidate
    {
        return $this->only(['application_name', 'application_type', 'app_id', 'app_secret', 'token', 'encoding_aes_key', 'additional_info']);
    }
} 